App({
  userSchedules: [[],[],[],[],[],[],[]],
  onLaunch: function(){
    var that = this
    wx.cloud.init()
    var db = wx.cloud.database()
    var openid
    var promise = wx.cloud.callFunction({
      name: "getOpenId"
    })
    async function getUserSchedules(){
      await promise.then(res=>{
        openid = res.result
      })
      db.collection("schedule").where({
        _openid: openid
      }).get({
        success: res =>{
          var utils = require("utils/utils.js")
          var all = res.data
          for(var i = 0; i <= all.length-1; i++){
            that.userSchedules[utils.weekToIndex(all[i].week)].push(all[i])
          }
          console.log(that.userSchedules)
        }
      })
    }
    getUserSchedules()
  }
})